//
//  AsiaSongDetailTableViewCell.m
//  LuckyRadio
//
//  Created by Mr、J on 15/11/17.
//  Copyright © 2015年 chenjun. All rights reserved.
//

#import "AsiaSongDetailTableViewCell.h"
#import <UIImageView+WebCache.h>

#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width

#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

#define WIDTH_PRO(X) (X)*(SCREEN_WIDTH/375)

#define HEIGHT_PRO(Y) (Y)*(SCREEN_HEIGHT/667)



@implementation AsiaSongDetailTableViewCell
- (void)dealloc
{
    [_asiaNewSongModel release];
    [_titleLabel release];
    [_detailLabel release];
    [_image release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews
{
    self.image = [UIImageView new];
    [self.contentView addSubview:self.image];
    [_image release];
    
    self.titleLabel = [UILabel new];
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.titleLabel];
    [_titleLabel release];
    
    self.detailLabel = [UILabel new];
    self.detailLabel.textColor = [UIColor grayColor];
    self.detailLabel.font = [UIFont systemFontOfSize:13];
    self.detailLabel.numberOfLines = 0;
    [self.contentView addSubview:self.detailLabel];
    [_detailLabel release];
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.image.frame = CGRectMake(WIDTH_PRO(10), 0, WIDTH_PRO(80), HEIGHT_PRO(80));
    self.titleLabel.frame = CGRectMake(self.image.frame.size.width + WIDTH_PRO(20), HEIGHT_PRO(20), SCREEN_WIDTH - WIDTH_PRO(100), HEIGHT_PRO(20));
    self.detailLabel.frame = CGRectMake(self.titleLabel.frame.origin.x, self.titleLabel.frame.origin.y + HEIGHT_PRO(30), SCREEN_WIDTH - WIDTH_PRO(100), HEIGHT_PRO(20));
}

-(void)setAsiaNewSongModel:(AsiaNewSongModel *)asiaNewSongModel
{
    if (_asiaNewSongModel != asiaNewSongModel) {
        [_asiaNewSongModel release];
        _asiaNewSongModel = [asiaNewSongModel retain];
    }
    
    [self.image sd_setImageWithURL:[NSURL URLWithString:asiaNewSongModel.picUrl] placeholderImage:[UIImage imageNamed:@"Read_zhanwei"]];
    self.titleLabel.text = asiaNewSongModel.name;
    self.detailLabel.text = asiaNewSongModel.desc;
    
    
    
}

+(AsiaSongDetailTableViewCell *)asiaSongDetailTableViewCellWith:(UITableView *)tableView
{
    static NSString *cellIdentifier = @"cellIdentifier";
    AsiaSongDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[AsiaSongDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
